Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Creating and using dynamic temp-tables
Temp-tables are one of the most important and useful constructs in an OpenEdge application. A temp-table lets you define in-memory storage for any number of rows of any combination of fields you require. A temp-table can be a mirror of a single database table, or it can be the result of a join of tables. It can contain a subset of selected fields from one or more tables, or it can contain fields that don’t map to any database fields at all. And it can be any combination of these things. In general, temp-tables give you two basic capabilities:
- A temp-table lets you create business logic that is independent of the particular structure of the underlying data source.
- A temp-table is the mechanism you use for passing records from one OpenEdge session to another, in particular from an AppServer session where the database resides to a client session where the user interface for the application is.
This chapter expands on your knowledge of temp-tables by introducing you to dynamic temp-tables. It also introduces you to the attributes you can access and the methods you can invoke using a handle to either a static or dynamic temp-table.
Finally, this chapter details the various ways in which you can pass a temp-table from one procedure or one session to another.
As with other objects, you can get the handle to a static temp-table and use that handle to query its attributes, using this syntax:
Having said this, however, a handle to a static temp-table is less useful than a handle to most other static objects, for two reasons:
These methods define the fields and indexes for the temp-table. You cannot change or extend the fields or indexes for a static temp-table.
To create a dynamic temp-table, use this statement:
There are no other options on the
CREATE TEMP-TABLEstatement. You specify everything about the table after you create it. Thus, theCREATEstatement really does nothing more than set up thett-handlevariable to be a handle for a temp-table structure to fill in later.A dynamic temp-table can be in one of three states. When you first create it, using just the
CREATE TEMP-TABLEstatement, it is said to be in the clear state. That is, the temp-table handle has been allocated but there is no definition for the table yet. After you start to use the temp-table methods to define the table’s fields and indexes, the table is said to be unprepared. This means that the table definition is not yet complete and you cannot start to use the table. After you complete the definition using its methods, you use a specialTEMP-TABLE-PREPAREmethod to signal to Progress that the definition is complete. This effectively freezes the definition and allows you to start to use the table to store data. At this point, the temp-table is in the prepared state.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |